package io.github.bigbird0101.easycluster.server;

import io.github.bigbird0101.easycluster.URL;

public abstract class AbstractServer implements Server {
    private final URL url;

    public AbstractServer(URL url){
        this.url=url;
    }

    @Override
    public URL getUrl() {
        return url;
    }

    public void start(){
        doStartBefore();
        doStart();
        doStartedSuccessAfter();
    }

    public void bind(){
        doBindBefore();
        doBind();
        doBoundSuccessAfter();
    }

    protected void doBoundSuccessAfter() {

    }

    protected abstract void doBind();

    protected void doBindBefore() {
    }

    /**
     * 启动
     */
    protected abstract void doStart();


    protected void doStartBefore() {

    }

    protected void doStartedSuccessAfter(){

    }
}
